package top.lywivan.array;

import top.lywivan.array.inf.List;

/**
 * @author :lyw.ivan
 * @date :Created in 2022/5/25
 * @description :
 * @version: 1.0
 */
public class ArrayListTest {
    public static void main(String[] args) {
        List list = new ArrayList(); //添加数据
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(5);
        System.out.println("索引为4的元素:"+list.get(4)); //5
        list.add(6);
        list.add(7);
        list.add(8);
        list.add(9);
        list.add(10);
        //再添就要扩容了
        list.add(11);
        System.out.println("size="+list.size()+"‐‐"+list); //11
        System.out.println("是否包含8:"+list.contains(8)+",集合容器是否为空:"+list.isEmpty()); //true false
        list.add(12);
        list.add(13);
        list.add(14);
        list.add(15);
        //既要扩容，元素又要后移
        list.add(13,141);
        System.out.println("size="+list.size()+"‐‐"+list); //16
        int set = list.set(13, 142);
        System.out.println("set方法返回的值:"+set+"‐‐完成后的list:"+list);
        int remove = list.remove(13);
        System.out.println("remove方法返回的值:"+remove+"‐‐remove后的list:"+list);
        list.clear(); System.out.println("clear之后:"+list);
    }
}